{include file="public/layout" /}

<body>
<link rel="stylesheet" href="__SKIN__/css/page.css" media="all">

<div class="layui-fluid" id="LAY-component-layer-list">
    <div class="layui-card">
        <div class="head-oper">
            <div class="fl">
                {eq name="$Think.const.CONTROLLER_NAME.'@add'|is_check_access" value="1"}
                <a data-url="{:url('Saleman/add')}" data-type="Saleman_add" class="layui-btn mt5 ">新增人员</a>
                {/eq}
            </div>
            <div class="fr">
                <form action="{:url('Saleman/index')}" method="get" onsubmit="layer_loading();">
                    <div class="fl mt5" >
                        <div class="layui-input-inline w240">
                            {$searchform.hidden|default=''}
                            <input type="hidden" name="pid" id="pid" value="{$Request.param.pid|default=''}">
                            <input type="text" name="keywords" id="keywords" value="{$Request.param.keywords}" placeholder="姓名搜索" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-input-inline w50 mt5">
                        <button class="layui-btn input-btn-search" type="submit"><i class="layui-icon layui-icon-search"></i></button>
                    </div>
                </form>
            </div>
        </div>
        <div class="layui-card-body">
            <div class="layui-form layui-border-box layui-table-view house-table" lay-filter="demo" lay-id="admin-arctype" >
                <div class="layui-table-box">
                    <div class="layui-table-body " >
                        <table cellspacing="0" cellpadding="0" border="0" class="layui-table layui-form" style="width: 100%" lay-skin="line">
                            <thead >
                            <tr>
                                <th class="w40 tc">
                                    <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                                        <input type="checkbox"  lay-filter="checkAll" class="checkAll"   lay-skin="primary" >
                                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary"> <i class="layui-icon layui-icon-ok"></i></div>
                                    </div>
                                </th>
                                <th class="w100 tc"> <div class="layui-table-cell w100 tc" ><span>ID</span></div></th>
                                <th class="wauto"> <div class="layui-table-cell wauto"><span>人员姓名</span></div></th>
                                <th class="w130 tc"> <div class="layui-table-cell w130 tc"><span>手机号码</span></div></th>
                                <th class="w120 tc"> <div class="layui-table-cell w120 tc"><span>QQ号码</span></div></th>
                                <th class="w80 tc"> <div class="layui-table-cell w80 tc"><span>启用</span></div></th>
                                <th class="w200 tc"> <div class="layui-table-cell w200 tc"><span>邮箱</span></div></th>
                                <th class="w80 tc"> <div class="layui-table-cell w80 tc"><span>排序</span></div></th>
                                <th class="w150 tc"> <div class="layui-table-cell w150 tc"><span>操作</span></div></th>
                            </tr>
                            </thead>
                            <tbody>
                            {empty name="list"}
                            <tr>
                                <td class="no-data" align="center" axis="col0" colspan="9">
                                    <i class="fa fa-exclamation-circle"></i>没有符合条件的数据
                                </td>
                            </tr>
                            {else /}
                            {foreach name="list" item="vo" key="k" }
                            <tr>
                                <td>
                                    <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                                        <input type="checkbox" name="ids[]" value="{$vo.id}" lay-filter="ids" lay-skin="primary">
                                    </div>
                                </td>
                                <td><div class="layui-table-cell w100 tc"> {$vo.id} </div></td>
                                <td>
                                    <div class="layui-table-cell wauto" title=" ">
                                        {notempty name="vo.saleman_pic"}
                                        <img src="__SKIN__/images/pic.gif" onmouseover="layer_tips=layer.tips('<img src={$vo.saleman_pic} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});" onmouseout="layer.close(layer_tips);">&nbsp;
                                        {/notempty}
                                        {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                        <a href="javascript:void(0);" class="eju-event" data-type="Saleman_edit" data-url="{:url('Saleman/edit',array('id'=>$vo['id']))}" >{$vo.saleman_name}</a>
                                        {else /}
                                        {$vo.saleman_name}
                                        {/eq}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w130 tc">
                                        {$vo.saleman_mobile}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w120 tc">
                                        {$vo.saleman_qq}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w80 tc">
                                        <input type="checkbox" name="status"  data-id="{$vo.id}" value="{$vo.status}" lay-filter="status" lay-skin="switch" lay-text="是|否" {if condition="$vo.status" value="1"} class="yes" checked{else /}class="no"{/if}>
                                    </div>
                                </td>
                                <td><div class="layui-table-cell w200 tc">  {$vo.saleman_email} </div></td>
                                <td>
                                    <div class="layui-table-cell w80 tc">
                                        <input type="text" onchange="changeTableVal('saleman','id','{$vo.id}','sort_order',this);" onkeyup="this.value=this.value.replace(/[^\d]/g,'');" onpaste="this.value=this.value.replace(/[^\d]/g,'');" size="4" value="{$vo.sort_order}" class="layui-input" />
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell w150 tc right-oper">
                                        {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                        <a data-url="{:url('Saleman/edit',array('id'=>$vo['id']))}" class="layui-btn btn-edit customvar_edit" data-type="Saleman_edit">
                                           编辑
                                        </a>
                                        {/eq}
                                        {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
                                        <a href="javascript:void(0);" data-url="{:url('Saleman/del')}" data-id="{$vo.id}" data-type="Saleman_del" class="layui-btn btn-primary">删除</a>
                                        {/eq}
                                    </div>
                                </td>
                            </tr>
                            {/foreach}
                            {/empty}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-table-page footer-oper">
                    <input type="checkbox" lay-filter="checkAll" class="checkAll" lay-skin="primary" >
                    {eq name="'Saleman@del'|is_check_access" value="1"}
                    <a class="layui-btn layui-btn-primary " data-type="batch_del" data-url="{:url('Saleman/del')}" style="line-height: 34px;">
                    批量删除
                    </a>
                    {/eq}
                </div>
                <!--分页-->

            </div>
            {$pageStr}
        </div>
    </div>
</div>

<script>
    layui.config({
        base: '__SKIN__/' //静态资源所在路径
        ,version: '{$version}'
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function(){
        var $ = layui.$
            ,form = layui.form
            ,table = layui.table;

        /* 触发事件 */
        var active = {
            Saleman_add: function(){
                var iframes = layer.open({
                    type: 2,
                    title: '新增人员',
                    fixed: true, //不固定
                    shadeClose: false,
                    shade: 0.3,
                    content: $(this).data('url')
                });
                layer.full(iframes);
            }
            ,Saleman_edit: function(){
                var iframes = layer.open({
                    type: 2,
                    title: '编辑人员',
                    fixed: true, //不固定
                    shadeClose: false,
                    shade: 0.3,
                    content: $(this).data('url')
                });
                layer.full(iframes);
            }
            ,Saleman_del: function(){
                delfun(this);
            }
            ,batch_del: function(){
                batch_del(this, 'ids');
            }
        };
        $('#LAY-component-layer-list .layui-btn,.eju-event').on('click', function(){
            var type = $(this).data('type');
            active[type] && active[type].call(this);
        });

        //开启关闭
        form.on('switch(status)', function(obj){
            var dataid = $(this).attr('data-id');
            if ($(this).val() == 1){
                $(this).val(0);
            }else{
                $(this).val(1);
            }
            changeTableVal('saleman','id',dataid,'status',this);
        });

        // 监听复选框全选
        form.on('checkbox(checkAll)', function(data){
            if (data.elem.checked) {
                $('.checkAll').attr('checked', true);
                $('input[name*=ids]').attr('checked', true);
            } else {
                $('.checkAll').attr('checked', false);
                $('input[name*=ids]').attr('checked', false);
            }
            form.render('checkbox');
        });

        // 监听每行复选框
        form.on('checkbox(ids)', function(data){
            if (data.elem.checked && $('input[name*=ids]:checked').length == $('input[name*=ids]').length) {
                $('.checkAll').attr('checked', true);
            } else {
                $('.checkAll').attr('checked', false);
            }
            form.render('checkbox');
        });
    });
</script>
{include file="public/footer" /}
